Import the Xend parts of xen-unstable changeset
authorEwan Mellor <ewan@xensource.com>
Wed, 1 Nov 2006 10:30:02 +0000 (10:30 +0000)
committerEwan Mellor <ewan@xensource.com>
Wed, 1 Nov 2006 10:30:02 +0000 (10:30 +0000)
11840:02506a7443155611d6bbf03e49fbf193e96d24db.

[HVM] Implement password authentication of VNC connections.

The specification is as mentioned at
http://lists.xensource.com/archives/html/xen-devel/2006-09/msg00666.html
(However, password came to describe plain text)

The difference is follows.
- protocol_authtype() without the necessity was deleted.
- The check on the protocol version was added.
- And, some small modification.

Signed-off-by: Masami Watanabe <masami.watanabe@jp.fujitsu.com>
tools/examples/xend-config.sxp
tools/python/xen/xend/XendRoot.py
tools/python/xen/xend/image.py
tools/python/xen/xm/create.py

index 9dacf7d3c675011e4bcc8ec8b073826d1ea9d61c..294d8e08def656e2d49a95e7e98cbfdbcdd52644 100644 (file)
 
 # The tool used for initiating virtual TPM migration
 #(external-migration-tool '')
+
+# The interface for VNC servers to listen on. Defaults
+# to 127.0.0.1  To restore old 'listen everywhere' behaviour
+# set this to 0.0.0.0
+#(vnc-listen '127.0.0.1')
+
+# The default password for VNC console on HVM domain.
+# Empty string is no authentication.
+(vncpasswd '')
index 3906cac6c7ec0438baf61c5cf7703fe51770fdd3..e098c9fad868ea4d8246436993b4198944ff769d 100644 (file)
@@ -93,6 +93,8 @@ class XendRoot:
 
     dom0_vcpus_default = '0'
 
+    vncpasswd_default = None
+
     """Default interface to listen for VNC connections on"""
     xend_vnc_listen_default = '127.0.0.1'
 
@@ -287,6 +289,10 @@ class XendRoot:
     def get_vnclisten_address(self):
         return self.get_config_value('vnc-listen', self.xend_vnc_listen_default)
 
+    def get_vncpasswd_default(self):
+        return self.get_config_value('vncpasswd',
+                                     self.vncpasswd_default)
+
 def instance():
     """Get an instance of XendRoot.
     Use this instead of the constructor.
index ee131d9841f2fdb61d3e25f0f19bf005395b16a3..dfbd139eb728b15c689423acb4b32e03d9353221 100644 (file)
@@ -354,23 +354,49 @@ class HVMImageHandler(ImageHandler):
         sdl = sxp.child_value(config, 'sdl')
         ret = []
         nographic = sxp.child_value(config, 'nographic')
+
+        # get password from VM config (if password omitted, None)
+        vncpasswd_vmconfig = sxp.child_value(config, 'vncpasswd')
+
         if nographic:
             ret.append('-nographic')
+            # remove password
+            if vncpasswd_vmconfig:
+                config.remove(['vncpasswd', vncpasswd_vmconfig])
             return ret
+
         if vnc:
             vncdisplay = sxp.child_value(config, 'vncdisplay',
                                          int(self.vm.getDomid()))
+
             vncunused = sxp.child_value(config, 'vncunused')
             if vncunused:
                 ret += ['-vncunused']
             else:
                 ret += ['-vnc', '%d' % vncdisplay]
+
             ret += ['-k', 'en-us']
+
             vnclisten = sxp.child_value(config, 'vnclisten')
             if not(vnclisten):
-                vnclisten = xen.xend.XendRoot.instance().get_vnclisten_address()
+                vnclisten = (xen.xend.XendRoot.instance().
+                             get_vnclisten_address())
             if vnclisten:
                 ret += ['-vnclisten', vnclisten]
+
+            vncpasswd = vncpasswd_vmconfig
+            if vncpasswd is None:
+                vncpasswd = (xen.xend.XendRoot.instance().
+                             get_vncpasswd_default())
+                if vncpasswd is None:
+                    raise VmError('vncpasswd is not set up in ' +
+                                  'VMconfig and xend-config.')
+            if vncpasswd != '':
+                self.vm.storeVm("vncpasswd", vncpasswd)
+
+        # remove password
+        config.remove(['vncpasswd', vncpasswd_vmconfig])
+
         return ret
 
     def createDeviceModel(self):
index 933ef84f5ca72005052eb71db5437b57019b217d..bfe967b504bb22b3cf5fcd39814904a7ee686fc0 100644 (file)
@@ -104,6 +104,10 @@ gopts.opt('console_autoconnect', short='c',
           fn=set_true, default=0,
           use="Connect to the console after the domain is created.")
 
+gopts.var('vncpasswd', val='NAME',
+          fn=set_value, default=None,
+          use="Password for VNC console on HVM domain.")
+
 gopts.var('vncviewer', val='no|yes',
           fn=set_bool, default=None,
            use="Spawn a vncviewer listening for a vnc server in the domain.\n"
@@ -660,6 +664,7 @@ def configure_hvm(config_image, vals):
     for a in args:
         if (vals.__dict__[a]):
             config_image.append([a, vals.__dict__[a]])
+    config_image.append(['vncpasswd', vals.vncpasswd])
 
 def run_bootloader(vals, config_image):
     if not os.access(vals.bootloader, os.X_OK):